package com.account.book.controller;

import com.account.book.common.response.BaseResult;
import com.account.book.common.response.ResultUtils;
import com.account.book.service.UploadFileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @author liang-hw
 * @className UploadFileController
 * @description 文件上传接口
 * @date 2023/11/09 15:02:40
 */
@RestController
@RequestMapping("/api/file")
@Api(tags = {"文件上传接口"})
public class UploadFileController {
    @Autowired
    private UploadFileService uploadFileService;

    /**
     * @param @param uploadFile
     * @return @return {@link BaseResult }<{@link List }<{@link String }>>
     * @author liang-hw
     * @description 上传文件
     * @date 2023/11/09 15:02:59
     */
    @ApiOperation(value = "上传文件", notes = "上传文件")
    @PostMapping("/upload")
    public BaseResult upload(@RequestParam("file") MultipartFile uploadFile, @RequestParam("type") Integer type) {
        return ResultUtils.success( uploadFileService.upload(uploadFile, type));
    }
}
